/*
 * @copyright fxsen <br/>
 * @date 2022/4/24 19:13 <br/>
 * @email <a href="mailto:fxsen@foxmail.com">
 * @author fxsen
 */
package com.fxsen.platform.web.controllers;

import com.fxsen.commons.core.base.result.ResponseResult;
import com.fxsen.commons.sysmanager.core.service.ILocalStorageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author fxsen
 * @date 2022/4/24 19:13
 * @email <a href="mailto:fxsen@foxmail.com">
 */
@RestController
@Api(tags = "工具：本地文件存储")
@RequestMapping("localStorage")
public class LocalStorageController {
    @Autowired
    private ILocalStorageService localStorageService;
    @PostMapping("upload")
    @ApiOperation(value = "上传文件")
    public ResponseResult upload(String fileName, MultipartFile multipartFile){
        try {
            return ResponseResult.success(localStorageService.create(fileName,multipartFile));
        }catch (Exception e){
            e.printStackTrace();
            return ResponseResult.failed();
        }
    }
}
